<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="s_menu" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="productRecordFormatSetSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button> 表格名称 <div class="form-unit">
            <span class="mvc-title-left"> 格式设置 </span>
          </div>
          <el-table :data="s_menu">
            <el-table-column label="操作" prop="" width="60">
              <template slot-scope="scope">
                <el-link @click="appendRow(s_menu,scope)" type='primary'><i class='el-icon-plus' title='增加行' /></el-link>
                <el-link @click="delRow(s_menu,scope)" type='danger'><i class='el-icon-minus' title='删除行' /></el-link>
              </template>
            </el-table-column>
            <el-table-column label="列名" prop="name">
              <template slot-scope="scope">
                <el-input v-model="scope.row.name" />
              </template>
            </el-table-column>
            <el-table-column label="单位" prop="record_table_sid">
              <template slot-scope="scope">
                <el-select style='width:100%' v-model="scope.row.record_table_sid">
                  <el-option label="－－无－－" value='' />
                </el-select>
              </template>
            </el-table-column>
          </el-table>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'记录设置'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'ProductRecordFormatSet',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        s_menu: [],
        loading: false,
        Container: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "0DE8485F0D57410993D741446A2B0598",
        name: "工艺编辑器右菜单",
        selected: "记录设置"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/product/ProcedureAction/productRecordFormatSet?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      productRecordFormatSetSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/mes/product/ProcedureAction/productRecordFormatSetSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/mes/product/ProductRecordFormat/productRecordFormat?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
    },
  }
</script>
